TakeSurvey = React.createClass(
  getInitialState: ->
    survey: null
  componentDidMount: ->
    $.getJSON("/survey/#{@props.id}", (json) ->
      @setState(survey: json)
    )
  render: ->
    if @state.survey
      <div>{@state.survey.title}</div>
    else
      null
)

appRouter =
  <Routes location='history'>
    <Route title='SurveyBuilder' handler={App}>
      <Route name='list' path='/' handler={ListSurveys} />
      <Route title='Add Survey to SurveyBuilder' name='add' path='/add_survey' handler={AddSurvey} />
      <Route name='edit' path='/surveys/:surveyId/edit' handler={EditSurvey} />
      <Route name='take' path='/surveys/:surveyId' handler={TakeSurveyCtrl} />
      <NotFound title='Page Not Found' handler={NotFoundHandler} />
    </Route>
  </Routes>

React.renderComponent(appRouter, document.querySelector('body'))
